package org.rsbot.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.PrintStream;

public class Serializer
{
  public static boolean serlialize(Object paramObject, File paramFile)
  {
    try
    {
      FileOutputStream localFileOutputStream = new FileOutputStream(paramFile);
      ObjectOutputStream localObjectOutputStream = new ObjectOutputStream(localFileOutputStream);
      localObjectOutputStream.writeObject(paramObject);
      localObjectOutputStream.close();
      localFileOutputStream.close();
    } catch (FileNotFoundException localFileNotFoundException) {
      System.out.println("File Not Found!");
      return false;
    } catch (IOException localIOException) {
      return false;
    }
    return true;
  }

  public static Object deserialize(InputStream paramInputStream) {
    Object localObject = null;
    try
    {
      ObjectInputStream localObjectInputStream = new ObjectInputStream(paramInputStream);
      localObject = localObjectInputStream.readObject();
      localObjectInputStream.close();
    } catch (FileNotFoundException localFileNotFoundException) {
    } catch (IOException localIOException) {
    }
    catch (ClassNotFoundException localClassNotFoundException) {
    }
    return localObject;
  }

  public static Object deserialize(File paramFile) {
    Object localObject = null;
    try {
      FileInputStream localFileInputStream = new FileInputStream(paramFile);
      deserialize(paramFile);
      localFileInputStream.close();
    } catch (Exception localException) {
    }
    return localObject;
  }
}